//
//  XQActionSheetCell.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/6.
//

import UIKit

class XQActionSheetCell: UITableViewCell {

    var cellInfo:XQActionSheetItem = XQActionSheetItem() {
        didSet {
            updateCell()
        }
    }
    
    fileprivate lazy var titleLbl: UILabel = {
        let lbl = UILabel()
        lbl.textColor = .xq_black
        lbl.textAlignment = .center
        return lbl
    }()
    
   fileprivate lazy var line: UILabel = {
        let lbl = UILabel()
        lbl.backgroundColor = UIColor(hex: "#EFEFEF")
        return lbl
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setLayout()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setLayout() {
       contentView.addSubview(line)
       line.snp.makeConstraints { (make) in
           make.bottom.trailing.leading.equalTo(self)
           make.height.equalTo(1)
       }
       contentView.addSubview(titleLbl)
       titleLbl.snp.makeConstraints { (make) in
           make.trailing.leading.top.equalTo(self)
           make.bottom.equalTo(line.snp.top)
       }
    }
   
    fileprivate func updateCell() {
       titleLbl.text = self.cellInfo.title
       titleLbl.font = cellInfo.titleFont
       titleLbl.textColor = cellInfo.titleColor
       self.backgroundColor = cellInfo.backgroundColor
       line.backgroundColor = cellInfo.bottomLineColor
       line.snp.updateConstraints { (make) in
           make.height.equalTo(cellInfo.bottomLineHeight)
        }
    }
       

}
